using System.Collections;
using UnityEngine;

public class StatsButton : MonoBehaviour
{
	public UILabel description;

	public UILabel player1;

	public UILabel player2;

	private GameStats.GameStatBase myStat;

	public void Init(GameStats.GameStatBase stat)
	{
		myStat = stat;
		if (stat.IsSingleValueResult())
		{
			player1.gameObject.SetActive(false);
			player2.gameObject.SetActive(false);
			string text = stat.GetDescription() + ": " + stat.ValuePlayer1();
			description.gameObject.SetActive(true);
			UITools.ChangeText(description, text);
		}
		else
		{
			description.gameObject.SetActive(true);
			UITools.ChangeText(description, stat.GetDescription());
			player1.gameObject.SetActive(true);
			UITools.ChangeText(player1, stat.ValuePlayer1());
			player2.gameObject.SetActive(true);
			UITools.ChangeText(player2, stat.ValuePlayer2());
		}
		base.gameObject.SetActive(true);
	}

	public void Init(string s1, string s2, string s3)
	{
		UITools.ChangeText(player1, s1);
		UITools.ChangeText(description, s2);
		UITools.ChangeText(player2, s3);
		base.gameObject.SetActive(true);
	}

	public Coroutine AnimateIn(float delay)
	{
		return StartCoroutine(DoAnimateIn(delay));
	}

	public IEnumerator DoAnimateIn(float delay)
	{
		UIWidget widget = GetComponent<UIWidget>();
		widget.alpha = 0f;
		yield return new WaitForSeconds(delay);
		float duration = 0.4f;
		StartCoroutine(UIAnimTools.DoFadeFromTo(widget, 0f, 1f, duration));
		yield return StartCoroutine(UIAnimTools.DoScaleFromTo(widget, new Vector3(4f, 0f, 1f), Vector3.one, duration));
	}
}
